#include "ui/PreviewDialog.h"
#include <QTextEdit>
#include <QSplitter>
#include <QVBoxLayout>
#include <QLabel>

PreviewDialog::PreviewDialog(QWidget *parent) : QDialog(parent)
{
    setWindowTitle("混淆预览");
    resize(800, 600);
    
    QVBoxLayout *layout = new QVBoxLayout(this);
    
    QSplitter *splitter = new QSplitter(Qt::Horizontal);
    
    QWidget *leftWidget = new QWidget;
    QVBoxLayout *leftLayout = new QVBoxLayout(leftWidget);
    leftLayout->addWidget(new QLabel("原始代码:"));
    m_originalText = new QTextEdit;
    m_originalText->setReadOnly(true);
    leftLayout->addWidget(m_originalText);
    
    QWidget *rightWidget = new QWidget;
    QVBoxLayout *rightLayout = new QVBoxLayout(rightWidget);
    rightLayout->addWidget(new QLabel("混淆后:"));
    m_obfuscatedText = new QTextEdit;
    m_obfuscatedText->setReadOnly(true);
    rightLayout->addWidget(m_obfuscatedText);
    
    splitter->addWidget(leftWidget);
    splitter->addWidget(rightWidget);
    
    layout->addWidget(splitter);
}

void PreviewDialog::setContent(const QString &original, const QString &obfuscated)
{
    m_originalText->setPlainText(original);
    m_obfuscatedText->setPlainText(obfuscated);
}